#include <math.h>
#include<stdio.h>
void change(int* arr_for, int* arr_last, int n, int m)
{
    int tem[20];
    int i = 0, j = 0, k = 0;
    while (1)
    {
        if (arr_for[i] < arr_last[j])
        {
            tem[k] = arr_for[i];
            i++;
        }
        else
        {
            tem[k] = arr_last[j];
            j++;
        }

        k++;
        if (i == n )
            break;

    

    }
    for (k; k < n + m; k++, j++)
    {
        tem[k] = arr_last[j];
    }
    for (int t = 0; t < m + n; t++)
        printf("%d ", tem[t]);
}
int main()
{
    int n, m;
    scanf_s("%d %d", &n, &m);
    int arr1[20];
    int arr2[20];
    for (int i = 0; i < n; i++)
    {
        scanf_s("%d", &arr1[i]);
    }
    for (int i = 0; i < m; i++)
    {
        scanf_s("%d", &arr2[i]);
    }
    if (arr1[n-1] <= arr2[m-1])
        change(arr1, arr2, n, m);
    else
        change(arr2, arr1, m, n);


    return 0;
}